const getToday = () => {
  const today = new Date();
  const start = new Date(
    today.getFullYear(),
    today.getMonth(),
    today.getDate() + 1
  );
  const end = new Date(
    today.getFullYear(),
    today.getMonth(),
    today.getDate() + 1
  );
  return {
    start: start.toISOString().split("T")[0] + " 00:00:00",
    end: end.toISOString().split("T")[0] + " 23:59:59",
  };
};
const getYesterday = () => {
  const yesterday = new Date();
  yesterday.setDate(yesterday.getDate());
  const start = new Date(
    yesterday.getFullYear(),
    yesterday.getMonth(),
    yesterday.getDate()
  );
  const end = new Date(
    yesterday.getFullYear(),
    yesterday.getMonth(),
    yesterday.getDate()
  );
  return {
    start: start.toISOString().split("T")[0] + " 00:00:00",
    end: end.toISOString().split("T")[0] + " 23:59:59",
  };
};
const getThisWeek = () => {
  const today = new Date();
  const start = new Date(today.setDate(today.getDate() - today.getDay()));
  const end = new Date(
    start.getFullYear(),
    start.getMonth(),
    start.getDate() + 7
  );
  return {
    start: start.toISOString().split("T")[0] + " 00:00:00",
    end: end.toISOString().split("T")[0] + " 23:59:59",
  };
};
const getLastWeek = () => {
  const today = new Date();
  const start = new Date(today.setDate(today.getDate() - today.getDay() - 7));
  const end = new Date(
    start.getFullYear(),
    start.getMonth(),
    start.getDate() + 7
  );
  return {
    start: start.toISOString().split("T")[0] + " 00:00:00",
    end: end.toISOString().split("T")[0] + " 23:59:59",
  };
};
const getThisMonth = () => {
  const today = new Date();
  const start = new Date(today.getFullYear(), today.getMonth(), 2);
  const end = new Date(today.getFullYear(), today.getMonth() + 1, 0);
  end.setHours(23, 59, 59, 999);
  return {
    start: start.toISOString().split("T")[0] + " 00:00:00",
    end: end.toISOString().split("T")[0] + " 23:59:59",
  };
};

export { getToday, getYesterday, getThisWeek, getLastWeek, getThisMonth };
